#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
int fun(int* arr, int n)
{
	int temp[1001];
	int res = 0;
	memset(temp, 0, sizeof(temp));
	for (int i = 0 , j = 0; i < n; i++) {
		temp[arr[i]]++;
		while (temp[arr[i]] > 1) {
			temp[arr[j++]]--;
		}
		res = max(res, i - j + 1);
	}
	return res;
}
int main()
{
	int n;
	cin >> n;
	int arr[1010];
	memset(arr, 0, sizeof(arr));
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int ret = fun(arr, n);
	cout << ret << endl;
	return 0;
}